<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<html lang="en">
<head>
    <th:block th:include="include :: header('修改配置信息')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body  class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-config-update" action="edit" method="post">
            <div class="form-group">
                <input name="id" type="hidden" th:value="${hondaConfig.id}" />
                <input id="about" name="about" type="hidden" th:value="${hondaConfig.about}">
                <label class="col-sm-3 control-label">关于我们：</label>
                <div class="col-sm-8">

                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <button id="edit" class="btn btn-primary btn-xs m-l-sm" onclick="editDetails()" type="button">编辑</button>
                            <button id="save" class="btn btn-primary  btn-xs" onclick="saveDetails()" type="button">保存</button>
                        </div>
                        <div class="ibox-content" id="eg">

                            <div class="click2edit wrapper">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">平台须知：</label>
                <div class="col-sm-9">
                    <textarea type="text" name="platformProtocol" class="form-control" placeholder="请输入平台须知" th:text="${hondaConfig.platformProtocol}"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客服电话：</label>
                <div class="col-sm-9">
                    <input type="text" name="customerMobile" class="form-control" placeholder="请输入客服电话" th:value="${hondaConfig.customerMobile}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">积分规则：</label>
                <div class="col-sm-9">
                    <textarea type="text" name="coinRule" class="form-control" placeholder="请输入购买规则" th:text="${hondaConfig.coinRule}"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">分享背景图片(630*1120)：</label>
                <div class="col-sm-8">
                    <button type="button" class="layui-btn" id="upload_home">上传图片</button>
                    <div class="layui-upload-list">
                        <input type="hidden" id="shareImg" th:value="${hondaConfig.shareImg}" name="shareImg">
                        <p id="show_home">
                            <img th:src="${hondaConfig.shareImg}">
                        </p>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12 col-sm-offset-3">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: summernote-js" />
</body>
<script>
    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });
    var content = $("#about").val();
    $('.click2edit').summernote('code', content);
    $('.click2edit').summernote('destroy');
    var editDetails = function () {
        $("#eg").addClass("no-padding");
        $('.click2edit').summernote({
            lang: 'zh-CN',
            focus: true
        });
    };
    var saveDetails = function () {
        $("#eg").removeClass("no-padding");
        var aHTML = $('.click2edit').summernote('code');
        $('.click2edit').summernote('destroy');
        $("#about").val(aHTML)
    };
    var prefix = ctx + "system/hondaconfig";
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/update", $('#form-config-update').serialize());
        }
    }


    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#upload_home'
            , url: ctx+'/common/upload?type=1' //改成您自己的上传接口
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                $("#show_home").html("<img src='" + res.url + "'>");
                $("#shareImg").val(res.url);
            }
        });
    })
</script>
</html>